##############################
# MAKE FOR ROTAT
##############################

  SYSTYPE := "gfortran"
UnixOrWin = "unix" # default value

# VPATH := ../ayudin/sparseUMF/

ifeq ($(SYSTYPE),"gfortran")
  FC = gfortran
#  FFLAGS = -c -O2 -freal-4-real-8 -ffixed-line-length-132 -fexpensive-optimizations -finit-local-zero -fno-automatic -Wall -ffpe-trap=zero,overflow
  FFLAGS = -c -O2 -ffixed-line-length-0 -fexpensive-optimizations -finit-local-zero -fno-automatic -Wall -ffpe-trap=zero,overflow -g -fbounds-check
  # FFLAGS = -c -g -fbounds-check -finit-local-zero -fno-automatic # for g77
  LDFLAGS =
#   LIBS= $(HOME)/lib/gfsparse.a $(HOME)/lib/gflnag.a -L/home/blinn/APUS/bin/pgplot -lpgplot -lpng -lX11
  LIBS=  -lpng -lpgplot -lX11
  LIBUMF = libumf.a
  LIBDIRSYS =
  LIBSM = /usr/local/lib/libplotsub.a \
        /usr/local/lib/libdevices.a \
        /usr/local/lib/libutils.a -L/usr/lib -lX11
  UnixOrWin := "unix"
endif
########################################

########################################
## For Linux
ifeq ($(UnixOrWin),"unix")
 LDFLAGS += -o
 slash_l := /
endif
#-------------------------------------------------------
#---
#-------------------------------------------------------

# f06efft.f contains dcopy
# f06ecft.f daxpy
# f06etft.f daxpyi*?

# OBJS_NAG := e01baft.o e01daft.o e01dalt.o e01damt.o e01dant.o e01dapt.o e01daqt.o e01dart.o e01dast.o e01datt.o\
#   e01daut.o e01davt.o e01dawt.o e01daxt.o e01dayt.o e01dazt.o e02baft.o e02bbft.o \
#   e02deft.o e02dezt.o e02dfvt.o e02dfwt.o e02dfxt.o \
#   f01brrt.o f01brqt.o f01brst.o f01brvt.o f01brut.o f01brwt.o f01brxt.o f01bryt.o f01brzt.o  \
#   f06ecft.f f06efft.o f06etft.o f06fbft.o \
#   p01abft.o p01abzt.o \
#   x01aaft.o x02ajft.o x02amft.o x04aaft.o x04abft.o x04baft.o


OBJS_NAG := lnag.o

OBJS_SPARSE := m28bys.o m28y12.o m28cys.o m28cyn.o m30y12.o

PROGNRMROT = nonRotmrot.exe
PROGNRMROT := $(subst /,$(slash_l),$(PROGNRMROT))
FILES_NRMROT = nonRotmrot.trf
OBJS_NRMROT := $(patsubst %.f,%.o, $(FILES_NRMROT:.trf=.f)) $(OBJS_SPARSE) $(OBJS_NAG)
CLEAN_NRMROT = nonRotmrot.trf

PROGMROT = mrot.exe
PROGMROT := $(subst /,$(slash_l),$(PROGMROT))
FILES_MROT = mrot.trf modulesRotOld.trf
OBJS_MROT := $(patsubst %.f,%.o, $(FILES_MROT:.trf=.f)) $(OBJS_SPARSE) $(OBJS_NAG)
CLEAN_MROT = mrot.trf modulesRotOld.trf

PROGMROTEOS = mroteos.exe
PROGMROTEOS := $(subst /,$(slash_l),$(PROGMROTEOS))
FILES_MROTEOS = mrotEos.trf modulesRotOld.trf eosGamma.f
OBJS_MROTEOS := $(patsubst %.f,%.o, $(FILES_MROTEOS:.trf=.f)) $(OBJS_SPARSE) $(OBJS_NAG)
CLEAN_MROTEOS = mrotEos.trf modulesRotOld.trf

PROGMROTEOSSEB = mroteosseb.exe
PROGMROTEOSSEB := $(subst /,$(slash_l),$(PROGMROTEOSSEB))
FILES_MROTEOSSEB = mrotEosSeb.trf eosGamma.f # or eosseb.trf
FILES_MROTEOSSEB = mrotEosSeb.trf $(OBJS_SPARSE) $(OBJS_NAG) eosseb.trf
OBJS_MROTEOSSEB := $(patsubst %.f,%.o, $(FILES_MROTEOSSEB:.trf=.f)) $(OBJS_SPARSE) $(OBJS_NAG)
CLEAN_MROTEOSSEB = mrotEosSeb.trf

PROGROT = newrot.exe
PROGROT := $(subst /,$(slash_l),$(PROGROT))
FILES_ROT = rotmain.trf rotsubr.trf eosaksenov.trf
OBJS_ROT := $(patsubst %.f,%.o, $(FILES_ROT:.trf=.f)) $(OBJS_SPARSE) $(OBJS_NAG)

PROGNRCANRHO = nrcanutorho.exe
PROGNRCANRHO := $(subst /,$(slash_l),$(PROGNRCANRHO))
FILES_NRCANRHO = nonRotrho0Canutomain.trf rotsubr.trf eosaksenov.trf
OBJS_NRCANRHO := $(patsubst %.f,%.o, $(FILES_NRCANRHO:.trf=.f)) $(OBJS_SPARSE) $(OBJS_NAG)

PROGCANRHO = canutorho.exe
PROGCANRHO := $(subst /,$(slash_l),$(PROGCANRHO))
FILES_CANRHO = rho0Canutomain.trf rotsubr.trf eosaksenov.trf modulesRotOld.trf
OBJS_CANRHO := $(patsubst %.f,%.o, $(FILES_CANRHO:.trf=.f)) $(OBJS_SPARSE) $(OBJS_NAG)
# FILES_CANRHO = rho0Canutomain.trf rotsubr.trf eosaksenov.trf \
# 	x04aaft.f x04abft.f x04baft.f p01abft.f
# OBJS_CANRHO := $(patsubst %.f,%.o, $(FILES_CANRHO:.trf=.f))
# OBJS_CANRHO := rho0Canutomain.o rotsubr.o eosaksenov.o $(OBJS_SPARSE) $(OBJS_NAG)

PROGYUDINRHOOLD = yudinrhoOld.exe
PROGYUDINRHOOLD:= $(subst /,$(slash_l),$(PROGYUDINRHOOLD))
FILES_YUDINRHOOLD = rho0Canutomain.trf rotsubr.trf eosyudin.trf modulesRotOld.trf
OBJS_YUDINRHOOLD := $(patsubst %.f,%.o, $(FILES_YUDINRHOOLD:.trf=.f)) $(OBJS_SPARSE) $(OBJS_NAG)


PROGCANROT = canutorot.exe
PROGCANROT := $(subst /,$(slash_l),$(PROGCANROT))
FILES_CANROT = rotCanutomain.trf rotsubr.trf eosaksenov.trf
OBJS_CANROT := $(patsubst %.f,%.o, $(FILES_CANROT:.trf=.f))
#FILES_CANROT = rotCanutomain.trf rotsubr.trf eosaksenov.trf
#OBJS_CANROT := $(patsubst %.f,%.o, $(FILES_CANROT:.trf=.f))
OBJS_CANROT := rotCanutomain.o rotsubr.o eosaksenov.o lnag.o
# $(OBJS_SPARSE) $(OBJS_NAG)

PROGPOLYT = polytrop.exe
PROGPOLYT := $(subst /,$(slash_l),$(PROGPOLYT))
FILES_POLYT = rotmain.trf rotsubrIR.trf eosGamma.f   # IR means Iterative Refinement
OBJS_POLYT := $(patsubst %.f,%.o, $(FILES_POLYT:.trf=.f))
CLEAN_POLYT = rotmain.trf rotsubrIR.trf

PROGPOLAW = polytlaw.exe
PROGPOLAW := $(subst /,$(slash_l),$(PROGPOLAW))
FILES_POLAW = rotLawmain.trf rotLawIRn.trf eosGamma.f # rotation Law is added as argument
OBJS_POLAW := $(patsubst %.f,%.o, $(FILES_POLAW:.trf=.f))
CLEAN_POLAW = rotLawmain.trf rotLawIRn.trf

PROGTURS = turseb.exe
PROGTURS := $(subst /,$(slash_l),$(PROGTURS))
FILES_TURS = tursEosseb.trf eosseb.trf
OBJS_TURS := $(patsubst %.f,%.o, $(FILES_TURS:.trf=.f))

PROGTURSG = tursgam.exe
PROGTURSG := $(subst /,$(slash_l),$(PROGTURSG))
FILES_TURSG = tursEosgam.trf eosGamma.f
OBJS_TURSG := $(patsubst %.f,%.o, $(FILES_TURSG:.trf=.f))
CLEAN_TURSG = tursEosgam.trf

PROGSEBRHON = sebrhon.exe
PROGSEBRHON := $(subst /,$(slash_l),$(PROGSEBRHON))
FILES_SEBRHON = rho0wise.trf rho0SebSubr.trf rotLawIRn.trf eosseb.trf vecsubs.trf interpolants.f polyfits.f \
   poly2timmes.f plot2db3.f pgcell.f dsqinf.f pgxtalm.f
OBJS_SEBRHON := $(patsubst %.f,%.o, $(FILES_SEBRHON:.trf=.f))
CLEAN_SEBRHON = rho0wise.trf rho0SebSubr.trf rotLawIRn.trf eosseb.trf

PROGSEBRHO = sebrho.exe
PROGSEBRHO := $(subst /,$(slash_l),$(PROGSEBRHO))
# FILES_SEBRHO = rho0Sebmain.trf rotsubrIR.trf eosseb.trf
# FILES_SEBRHO = rho0Sebmain.trf rotLawIRn.trf modulesRotOld.trf eosseb.trf vecsubs.trf interpolants.f polyfits.f
FILES_SEBRHO = rho0Sebmain.trf rotLawIRn.trf modulesRotOld.trf eosseb.trf \
   poly2timmes.f plot2db3.f pgcell.f dsqinf.f pgxtalm.f collaplaw.for
# OBJS_SEBRHO := $(patsubst %.f,%.o, $(FILES_SEBRHO:.trf=.f))  $(OBJS_SPARSE) $(OBJS_NAG)
OBJS_SEBRHO := $(patsubst %.f,%.o, $(FILES_SEBRHO:.trf=.f))  $(OBJS_NAG)
CLEAN_SEBRHO = rho0Sebmain.trf rotLawIRn.trf modulesRotOld.trf eosseb.trf

PROGSEBRHODAN = sebrhodan.exe
PROGSEBRHODAN := $(subst /,$(slash_l),$(PROGSEBRHODAN))
# FILES_SEBRHO = rho0Sebmain.trf rotsubrIR.trf eosseb.trf
FILES_SEBRHODAN = rho0Sebmain_jm.trf rotLawIR_jm.trf modulesRotOld_jm.trf eosseb.trf vecsubs.trf interpolants.f polyfits.f \
   poly2timmes.f plot2db3.f pgcell.f dsqinf.f pgxtalm.f collaplaw.for
OBJS_SEBRHODAN := $(patsubst %.f,%.o, $(FILES_SEBRHODAN:.trf=.f))  $(OBJS_SPARSE) $(OBJS_NAG)
CLEAN_SEBRHODAN = rho0Sebmain_jm.trf rotLawIR_jm.trf modulesRotOld_jm.trf eosseb.trf

PROGSEBCANRHO= sebcanrho.exe
PROGSEBCANRHO:= $(subst /,$(slash_l),$(PROGSEBCANRHO))
# FILES_SEBRHO = rho0Sebmain.trf rotsubrIR.trf eosseb.trf
FILES_SEBCANRHO = rho0SebCanmain.trf rotLawIRn.trf modulesRotOld.trf eosaksenov.trf vecsubs.trf interpolants.f polyfits.f \
   poly2timmes.f plot2db3.f pgcell.f dsqinf.f pgxtalm.f collaplaw.for
OBJS_SEBCANRHO:= $(patsubst %.f,%.o, $(FILES_SEBCANRHO:.trf=.f))  $(OBJS_SPARSE) $(OBJS_NAG)
CLEAN_SEBCANRHO = rho0SebCanmain.trf rotLawIRn.trf modulesRotOld.trf eosseb.trf

PROGSEBYUDINRHO= sebyudinrho.exe
PROGSEBYUDINRHO:= $(subst /,$(slash_l),$(PROGSEBYUDINRHO))
# FILES_SEBRHO = rho0Sebmain.trf rotsubrIR.trf eosseb.trf
# polyfits.f vecsubs.trf  interpolants.f
FILES_SEBYUDINRHO = rho0SebCanmain.trf rotLawIRn.trf modulesRotOld.trf eosyudin.trf  \
   poly2timmes.f plot2db3.f pgcell.f dsqinf.f pgxtalm.f collaplaw.for lnag.f
OBJS_SEBYUDINRHO:= $(patsubst %.f,%.o, $(FILES_SEBYUDINRHO:.trf=.f))
CLEAN_SEBYUDINRHO = rho0SebCanmain.trf rotLawIRn.trf modulesRotOld.trf eosyudin.trf

PROGSHYUDINY12M= shyudiny12m.exe
PROGSHYUDINY12M:= $(subst /,$(slash_l),$(PROGSHYUDINY12M))
# FILES_SEBRHO = rho0Sebmain.trf rotsubrIR.trf eosseb.trf
FILES_SHYUDINY12M = rho0Yudinmain.trf rotLawY12M.trf modulesRotOld.trf eosyudin.trf \
   poly2timmes.f plot2db3.f pgcell.f dsqinf.f pgxtalm.f collaplaw.for y12m.f lnag.f
OBJS_SHYUDINY12M:= $(patsubst %.f,%.o, $(FILES_SHYUDINY12M:.trf=.f))
CLEAN_SHYUDINY12M = rho0Yudinmain.trf rotLawY12M.trf modulesRotOld.trf eosyudin.trf

PROGSHYUDINRHO= shyudinrho.exe
PROGSHYUDINRHO:= $(subst /,$(slash_l),$(PROGSHYUDINRHO))
# FILES_SEBRHO = rho0Sebmain.trf rotsubrIR.trf eosseb.trf
FILES_SHYUDINRHO = rho0Yudinmain.trf rotLawIRn.trf modulesRotOld.trf eosyudin.trf \
   poly2timmes.f plot2db3.f pgcell.f dsqinf.f pgxtalm.f collaplaw.for lnag.f
OBJS_SHYUDINRHO:= $(patsubst %.f,%.o, $(FILES_SHYUDINRHO:.trf=.f))
CLEAN_SHYUDINRHO = rho0Yudinmain.trf rotLawIRn.trf modulesRotOld.trf eosyudin.trf
# lnag.f instead of  vecsubs.trf interpolants.f  polyfits.f $(OBJS_SPARSE) $(OBJS_NAG)

PROGUMFYUDINRHO= umfyudinrho.exe
PROGUMFYUDINRHO:= $(subst /,$(slash_l),$(PROGUMFYUDINRHO))
# FILES_SEBRHO = rho0Sebmain.trf rotsubrIR.trf eosseb.trf
FILES_UMFYUDINRHO = rho0Yudinmain.trf rotLawIRumf.trf modulesRotOld.trf eosyudin.trf \
   poly2timmes.f plot2db3.f pgcell.f dsqinf.f pgxtalm.f collaplaw.for lnag.f
OBJS_UMFYUDINRHO:= $(patsubst %.f,%.o, $(FILES_UMFYUDINRHO:.trf=.f))
CLEAN_UMFYUDINRHO = rho0Yudinmain.trf rotLawIRumf.trf modulesRotOld.trf eosyudin.trf
# lnag.f instead of  vecsubs.trf interpolants.f  polyfits.f $(OBJS_SPARSE) $(OBJS_NAG)

PROGSHYUDINHPRHO= shyudinhprho.exe
PROGSHYUDINHPRHO:= $(subst /,$(slash_l),$(PROGSHYUDINHPRHO))
FILES_SHYUDINHPRHO = rho0Yudinmain.trf rotLawIRn.trf modulesRotOld.trf eoshpFPS.trf vecsubs.trf interpolants.f polyfits.f \
   poly2timmes.f plot2db3.f pgcell.f dsqinf.f pgxtalm.f collaplaw.for
OBJS_SHYUDINHPRHO:= $(patsubst %.f,%.o, $(FILES_SHYUDINHPRHO:.trf=.f))  $(OBJS_SPARSE) $(OBJS_NAG)
CLEAN_SHYUDINHPRHO = rho0Yudinmain.trf rotLawIRn.trf modulesRotOld.trf eoshpFPS.trf

PROGNRSEBRHO = nrsebrho.exe
PROGNRSEBRHO := $(subst /,$(slash_l),$(PROGNRSEBRHO))
FILES_NRSEBRHO = nrrho0Seb.trf rotLawIRn.trf eosseb.trf vecsubs.trf interpolants.f polyfits.f \
 poly2timmes.f plot2db3.f pgcell.f dsqinf.f pgxtalm.f
OBJS_NRSEBRHO := $(patsubst %.f,%.o, $(FILES_NRSEBRHO:.trf=.f))
CLEAN_NRSEBRHO = nrrho0Seb.trf rotLawIRn.trf eosseb.trf

PROGNRgamrho = nrgamrho.exe
PROGNRgamrho := $(subst /,$(slash_l),$(PROGNRgamrho))
FILES_NRgamrho = nrrho0Seb.trf rotLawIRn.trf eosGamma.f vecsubs.trf interpolants.f polyfits.f \
 poly2timmes.f plot2db3.f pgcell.f dsqinf.f pgxtalm.f
OBJS_NRgamrho := $(patsubst %.f,%.o, $(FILES_NRgamrho:.trf=.f))
CLEAN_NRgamrho = nrrho0Seb.trf rotLawIRn.trf

PROGMfromJ = findMfromJ.exe
PROGMfromJ := $(subst /,$(slash_l),$(PROGMfromJ))
FILES_MfromJ = findMfromJ.trf
OBJS_MfromJ := $(patsubst %.f,%.o, $(FILES_MfromJ:.trf=.f))

PROGNRRHONP = nrrhoNoPlots.exe
PROGNRRHONP := $(subst /,$(slash_l),$(PROGNRRHONP))
FILES_NRRHONP = nrrho0NoPlots.trf rotLawIRn.trf eosseb.trf  plot2db3.f pgcell.f dsqinf.f pgxtalm.f
OBJS_NRRHONP := $(patsubst %.f,%.o, $(FILES_NRRHONP:.trf=.f))
CLEAN_NRRHONP = nrrho0NoPlots.trf rotLawIRn.trf eosseb.trf

PROGPOLRHO = polrho.exe
PROGPOLRHO := $(subst /,$(slash_l),$(PROGPOLRHO))
FILES_POLRHO = rho0Sebmain.trf rotLawIRn.trf eosGamma.f
OBJS_POLRHO := $(patsubst %.f,%.o, $(FILES_POLRHO:.trf=.f))

PROGPLOTRT = plotrt.exe # plot in r, theta plane
PROGPLOTRT := $(subst /,$(slash_l),$(PROGPLOTRT))
FILES_PLOTRT = plotPhiRthet.trf plot2db3.f pgcell.f dsqinf.f pgxtalm.f
OBJS_PLOTRT := $(patsubst %.f,%.o, $(FILES_PLOTRT:.trf=.f))
CLEAN_PLOTRT = plotPhiRthet.trf

PROGPLOT = plot2rot.exe # main plotting in cylinder coordinates
PROGPLOT := $(subst /,$(slash_l),$(PROGPLOT))
FILES_PLOT = modulesRotOld.trf plot2rot.trf plot2db3.f pgcell.f dsqinf.f pgxtalm.f lnag.f
OBJS_PLOT := $(patsubst %.f,%.o, $(FILES_PLOT:.trf=.f))
CLEAN_PLOT = plot2rot.trf modulesRotOld.trf
# $(OBJS_NAG)

PROGAK1D = akimarot1.exe
PROGAK1D := $(subst /,$(slash_l),$(PROGAK1D))
FILESAK1D = akimarot.trf akima.new.f tripack.f plot2db3.f pgcell.f dsqinf.f pgxtalm.f
OBJSAK1D := $(patsubst %.f,%.o, $(FILESAK1D:.trf=.f))
CLEAN_AK1D = akimarot.trf

PROGAK2D = akimarot2.exe
PROGAK2D := $(subst /,$(slash_l),$(PROGAK2D))
FILESAK2D = akimarot2.trf akima.new.f tripack.f plot2db3.f pgcell.f dsqinf.f pgxtalm.f
OBJSAK2D := $(patsubst %.f,%.o, $(FILESAK2D:.trf=.f))
CLEAN_AK2D = akimarot2.trf

DEL = rm -f

TREFOR = trf

# it is very important to show exact path for shared libraries with -Wl,-rpath option below,
# because different compilers use different libraries

# Lines from here on down should not need to be changed.  They are the
# actual rules which make uses to build the executable
#


# for ctrf:
TRFFLAGS = -nfs

.IGNORE:
%.o : %.trf
	$(TREFOR) $(TRFFLAGS) $<
	$(FC) $(FFLAGS) $(subst /,$(slash_l),$(patsubst %.trf,%.f,$<))

#.SUFFIXES: $(SUFFIXES) .f


%.o: %.f
	$(FC) $(FFLAGS) $(subst /,$(slash_l),$<)

%.mod : %.o
	@if [! -f $@ ]; then \
	  rm $< \
	  $(MAKE) $< \
	fi

%.o : %.f90
	$(FC) $(FFLAGS) $(subst /,$(slash_l),$<)


all: help
	@echo current compiler: $(FC)
	@echo and its options : $(FFLAGS)

nrmrot: $(OBJS_NRMROT)
	$(FC) $(LDFLAGS) $(PROGNRMROT) $(OBJS_NRMROT) $(LIBS) $(LIBDIRSYS)

mrot: $(OBJS_MROT)
	$(FC) $(LDFLAGS) $(PROGMROT) $(OBJS_MROT) $(LIBS) $(LIBDIRSYS)

mroteos: $(OBJS_MROTEOS)
	$(FC) $(LDFLAGS) $(PROGMROTEOS) $(OBJS_MROTEOS) $(LEOSIBS) $(LIBDIRSYS)

mroteosseb: $(OBJS_MROTEOSSEB)
	$(FC) $(LDFLAGS) $(PROGMROTEOSSEB) $(OBJS_MROTEOSSEB) $(LIBS) $(LIBDIRSYS)

rot: $(OBJS_ROT)
	$(FC) $(LDFLAGS) $(PROGROT) $(OBJS_ROT) $(LIBS) $(LIBDIRSYS)

nrcanutorho: $(OBJS_NRCANRHO)
	$(FC) $(LDFLAGS) $(PROGNRCANRHO) $(OBJS_NRCANRHO) $(LIBS) $(LIBDIRSYS)

canutorho: $(OBJS_CANRHO)
	$(FC) $(LDFLAGS) $(PROGCANRHO) $(OBJS_CANRHO)

yudinrhoold: $(OBJS_YUDINRHOOLD)
	$(FC) $(LDFLAGS) $(PROGYUDINRHOOLD) $(OBJS_YUDINRHOOLD)

canutorot: $(OBJS_CANROT)
	$(FC) $(LDFLAGS) $(PROGCANROT) $(OBJS_CANROT) $(LIBS) $(LIBDIRSYS)

polytrop: $(OBJS_POLYT)
	$(FC) $(LDFLAGS) $(PROGPOLYT) $(OBJS_POLYT) $(LIBS) $(LIBDIRSYS)

polytlaw: $(OBJS_POLAW)
	$(FC) $(LDFLAGS) $(PROGPOLAW) $(OBJS_POLAW) $(LIBS) $(LIBDIRSYS)

turs: $(OBJS_TURS)
	$(FC) $(LDFLAGS) $(PROGTURS) $(OBJS_TURS)

tursgam: $(OBJS_TURSG)
	$(FC) $(LDFLAGS) $(PROGTURSG) $(OBJS_TURSG)

sebrhon: $(OBJS_SEBRHON)
	$(FC) $(LDFLAGS) $(PROGSEBRHON) $(OBJS_SEBRHON) $(LIBS) $(LIBSM) $(LIBDIRSYS)

sebrho: $(OBJS_SEBRHO)
	$(FC) $(LDFLAGS) $(PROGSEBRHO) $(OBJS_SEBRHO) $(LIBS) $(LIBSM) $(LIBDIRSYS)

sebrhodan: $(OBJS_SEBRHODAN)
	$(FC) $(LDFLAGS) $(PROGSEBRHODAN) $(OBJS_SEBRHODAN) $(LIBS) $(LIBSM) $(LIBDIRSYS)

sebcanrho: $(OBJS_SEBCANRHO)
	$(FC) $(LDFLAGS) $(PROGSEBCANRHO) $(OBJS_SEBCANRHO) $(LIBS) $(LIBSM) $(LIBDIRSYS)

sebyudinrho: $(OBJS_SEBYUDINRHO)
	$(FC) $(LDFLAGS) $(PROGSEBYUDINRHO) $(OBJS_SEBYUDINRHO) $(LIBS) $(LIBSM) $(LIBDIRSYS)

shyudiny12m: $(OBJS_SHYUDINY12M)
	$(FC) $(LDFLAGS) $(PROGSHYUDINY12M) $(OBJS_SHYUDINY12M) $(LIBS) $(LIBDIRSYS)

shyudinrho: $(OBJS_SHYUDINRHO)
	$(FC) $(LDFLAGS) $(PROGSHYUDINRHO) $(OBJS_SHYUDINRHO) $(LIBS) $(LIBDIRSYS)

umfyudinrho: $(OBJS_UMFYUDINRHO)
	$(FC) $(LDFLAGS) $(PROGUMFYUDINRHO) $(OBJS_UMFYUDINRHO) $(LIBUMF) $(LIBS) $(LIBDIRSYS)

libumf: umfpack_2.0_prompt.o
	$(FC) -freal-4-real-8 $(FFLAGS) umfpack_2.0_prompt.f
	ar cvr libumf.a umfpack_2.0_prompt.o

shyudinhprho: $(OBJS_SHYUDINHPRHO)
	$(FC) $(LDFLAGS) $(PROGSHYUDINHPRHO) $(OBJS_SHYUDINHPRHO) $(LIBS) $(LIBDIRSYS)

MfromJ: $(OBJS_MfromJ)
	$(FC) $(LDFLAGS) $(PROGMfromJ) $(OBJS_MfromJ) $(LIBS) $(LIBDIRSYS)

nrsebrho: $(OBJS_NRSEBRHO)
	$(FC) $(LDFLAGS) $(PROGNRSEBRHO) $(OBJS_NRSEBRHO) $(LIBS) $(LIBSM) $(LIBDIRSYS)

nrgamrho: $(OBJS_NRgamrho)
	$(FC) $(LDFLAGS) $(PROGNRgamrho) $(OBJS_NRgamrho) $(LIBS) $(LIBSM) $(LIBDIRSYS)

nrrhonp: $(OBJS_NRRHONP)
	$(FC) $(LDFLAGS) $(PROGNRRHONP) $(OBJS_NRRHONP) $(LIBS) $(LIBDIRSYS)

polrho: $(OBJS_POLRHO)
	$(FC) $(LDFLAGS) $(PROGPOLRHO) $(OBJS_POLRHO) $(LIBS) $(LIBDIRSYS)

plotrt: $(OBJS_PLOTRT)
	$(FC) $(LDFLAGS) $(PROGPLOTRT) $(OBJS_PLOTRT) $(LIBS)

plot: $(OBJS_PLOT)
	$(FC) $(LDFLAGS) $(PROGPLOT) $(OBJS_PLOT) $(LIBS)

akima1: $(OBJSAK1D)
	$(FC) $(LDFLAGS) $(PROGAK1D)  $(OBJSAK1D) $(LIBS)

akima2: $(OBJSAK2D)
	$(FC) $(LDFLAGS) $(PROGAK2D)  $(OBJSAK2D) $(LIBS)

help:
	@echo "You can do: "
	@echo " nrmrot         --  compile non-rot mrot test for polytropes"
	@echo " mrot           --  compile mrot for polytropes"
	@echo " mroteos        --  compile mroteos for arbitrary EoS"
	@echo " mroteosseb     --  compile mroteosseb for rho-seq and any EoS"
	@echo " rot            --  compile newrot"
	@echo " nrcanutorho    --  compile non-rot-canutorho: rho0 series"
	@echo " canutorho      --  compile canutorho: rho0 series"
	@echo " yudinrhoold    --  compile yudinrhoOld: too old code rho0Canutomain rho0 series"
	@echo " canutorot      --  compile canutorot: IB series"
	@echo " polytrop       --  compile polytrop with alpha-law"
	@echo " polytlaw       --  compile polytrop with rot law"
	@echo " turs           --  compile tursEosseb.trf eosseb.trf "
	@echo " tursgam        --  compile tursEosgam.trf eosGamma.f "
	@echo " sebrhon        --  compile sebrhon: wise finding IB for given J "
	@echo " sebrho         --  compile sebrho: rho0 series"
	@echo " sebrhodan      --  compile sebrhodan: rho0 series for j(m)"
	@echo " sebcanrho      --  compile sebcanrho: rho0 series"
	@echo " sebyudinrho    --  compile sebyudinrho: rho0 series with supermongo"
	@echo " shyudiny12m    --  compile shyudinY12M: rho0 series -- no supermongo, sparse Y12M"
	@echo " shyudinrho     --  compile shyudinrho:  rho0 series -- no supermongo, sparse M28Y12"
	@echo " libumf         --  build libumf"
	@echo " umfyudinrho    --  compile umfyudinrho: rho0 series -- no supermongo, sparse UMF"
	@echo " shyudinhprho   --  compile shyudinhprho: rho0 series -- no supermongo"
	@echo " MfromJ         --  compile findMfromJ given rho in rho0MJ.out find M for fixed J"
	@echo " nrsebrho       --  compile non-rot nrsebrho: rho0 series"
	@echo " nrgamrho       --  compile non-rot nrgamrho: rho0 series"
	@echo " nrrhonp        --  compile non-rot rho0 series No Plot files"
	@echo " polrho         --  compile polrho: rho0 series for polytropes"
	@echo " plotrt         --  compile plotrt in r, theta plane"
	@echo " plot           --  compile plot2rot main plotting"
	@echo " akima1         --  compile akimarot1"
	@echo " akima2         --  compile akimarot2"
	@echo " cleandata      --  DEL nohup.out core* fort.*"
	@echo " clean          --  DEL *.o *.il and *.f from trf"
	@echo " cleanall       --  DEL PROGROT *.o *.il  *.mod *.lst"
	@echo " help           --  print this help"

#
# Here are all the dependencies:
#


######
# ROTAT
######
nonRotmrot.o    :  nonRotmrot.trf PPMA.inc STATD.inc
mrot.o          :  mrot.trf modulesRotOld.o grid.inc #PPMA.inc STATD.inc
mrotEos.o       :  mrotEos.trf modulesRotOld.o grid.inc #PPMA.inc  statd.for
mrotEosSeb.o    :  mrotEosSeb.trf PPMA.inc WDunits.inc grid.inc
rotmain.o       :  rotmain.trf  accur.for grid.inc
nonRotrho0Canutomain.o : nonRotrho0Canutomain.trf accur.for statd.for
rho0Canutomain.o:  rho0Canutomain.trf  accur.for grid.inc
rotCanutomain.o :  rotCanutomain.trf  accur.for grid.inc
rho0wise.o      :  rho0wise.trf accur.inc grid.inc WDunits.inc
rho0SebSubr.o   :  rho0SebSubr.trf accur.inc grid.inc WDunits.inc
# rho0Sebmain.o   :  rho0Sebmain.trf  accur.inc grid.inc WDunits.inc # statd.for units.inc
rho0Sebmain.o   :  rho0Sebmain.trf  modulesRotOld.o grid.inc WDunits.inc # statd.for units.inc
rho0Sebmain_jm.o   :  rho0Sebmain_jm.trf  modulesRotOld_jm.o grid.inc WDunits.inc # statd.for units.inc
rho0SebCanmain.o   :  rho0SebCanmain.trf  modulesRotOld.o grid.inc WDunits.inc # statd.for units.inc
rho0Yudinmain.o  : rho0Yudinmain.trf modulesRotOld.o grid.inc WDunits.inc # statd.for units.inc
findMfromJ.o    :  findMfromJ.trf
nrrho0Seb.o     :  nrrho0Seb.trf  accur.inc grid.inc WDunits.inc # statd.for units.inc
nrrho0NoPlots.o :  nrrho0NoPlots.trf  accur.inc grid.inc WDunits.inc # statd.for units.inc
rotLawmain.o    :  rotLawmain.trf  accur.inc grid.inc # statd.for
rotsubr.o       :  rotsubr.trf  accur.for grid.inc # statd.for
rotsubrIR.o     :  rotsubrIR.trf  accur.inc grid.inc # statd.for
# rotLawIRn.o      :  rotLawIRn.trf  accur.inc grid.inc # statd.for
rotLawIRn.o      :  rotLawIRn.trf modulesRotOld.o grid.inc # statd.for
rotLawIRumf.o   :  rotLawIRumf.trf modulesRotOld.o grid.inc # statd.for
rotLawIR_jm.o   :  rotLawIR_jm.trf modulesRotOld_jm.o grid.inc # statd.for
eosaksenov.o    :  eosaksenov.trf accur.for
eosyudin.o      :  eosyudin.trf accur.for
eoshpFPS.o      :  eoshpFPS.trf accur.for
eosseb.o        :  eosseb.trf WDunits.inc
eosGamma.o      :  eosGamma.f accur.for
poly2timmes.f   :  implno.dek const.dek
stat1.o         :  stat1.f  accur.for statd.for
stat1fdat.o     :  stat1fdat.f  accur.for statd.for
stat2.o         :  stat2.f  accur.for statd.for
modulesRotOld.o :  modulesRotOld.trf grid.inc
modulesRotOld_jm.o :  modulesRotOld_jm.trf grid.inc

######
# TOOLS, NUMERICS, NAG source, ETC
######

vecsubs.o       :  vecsubs.trf
interpolants.o  :  interpolants.f
polyfits.o      :  polyfits.f

######
# TEST
######
tursEosseb.o    :  tursEosseb.trf units.inc
tursEosgam.o    :  tursEosgam.trf units.inc

######
# PLOT
######
plot2rot.o      :  plot2rot.trf plotrot.inc  grid.inc # statd.for # we need statd.for for old versions
akimarot.o      :  akimarot.trf
akimarot2.o     :  akimarot2.trf
akima.new.o     :  akima.new.f
tripack.o       :  tripack.f
plot2db3.o      :  plot2db3.f
pgcell.o        :  pgcell.f
dsqinf.o        :  dsqinf.f
pgxtalm.o       :  pgxtalm.f

######
# SPARSE
######
m28bys.o: m28bys.trf
m28y12.o: m28y12.f
m28cys.o: m28cys.trf
m28cyn.o: m28cyn.trf
m30y12.o: m30y12.trf

umfpack_2.0_prompt.o: umfpack_2.0_prompt.f

cleandata:
	$(DEL) nohup.out core* fort.*

clean:
	$(DEL) *.o  *.il
	$(DEL) $(CLEAN_POLYT:.trf=.f) $(CLEAN_POLAW:.trf=.f) $(FILES_TURS:.trf=.f) \
	       $(CLEAN_MROT:.trf=.f) $(CLEAN_MROTEOS:.trf=.f) $(CLEAN_MROTEOSSEB:.trf=.f) \
	       $(FILES_ROT:.trf=.f) $(FILES_CANRHO:.trf=.f)  $(FILES_CANROT:.trf=.f) \
	       $(CLEAN_PLOT:.trf=.f) $(CLEAN_PLOTRT:.trf=.f) $(CLEAN_TURSG:.trf=.f) \
		$(CLEAN_SEBRHO:.trf=.f) $(CLEAN_SEBCANRHO:.trf=.f) $(CLEAN_NRSEBRHO:.trf=.f) \
		$(CLEAN_NRRHONP:.trf=.f) $(CLEAN_SHYUDINRHO:.trf=.f) $(CLEAN_UMFYUDINRHO:.trf=.f) \
		$(CLEAN_AK1D:.trf=.f) $(CLEAN_AK2D:.trf=.f)


cleanall:
	$(DEL) $(PROGROT) $(PROGCANRHO) $(PROGCANROT) $(PROGPOLYT) $(PROGPOLAW) \
	$(PROGTURS) $(PROGTURSG) $(PROGPLOT)  $(PROGMROT) $(PROGMROTEOS) \
	$(PROGSEBRHO) $(PROGPOLRHO) $(PROGSHYUDINY12M) $(PROGSHYUDINRHO) $(PROGUMFYUDINRHO) *.o  *.il
	$(DEL) $(CLEAN_POLYT:.trf=.f) $(CLEAN_POLAW:.trf=.f) $(FILES_TURS:.trf=.f) \
	       $(CLEAN_MROT:.trf=.f) $(CLEAN_MROTEOS:.trf=.f) \
	       $(FILES_ROT:.trf=.f) $(FILES_CANRHO:.trf=.f)  $(FILES_CANROT:.trf=.f) \
	       $(CLEAN_PLOT:.trf=.f) $(CLEAN_PLOTRT:.trf=.f)  $(CLEAN_TURSG:.trf=.f) \
	   $(CLEAN_SEBRHON:.trf=.f) $(CLEAN_SEBRHO:.trf=.f) $(CLEAN_SEBCANRHO:.trf=.f) \
	   $(CLEAN_NRSEBRHO:.trf=.f) $(CLEAN_NRRHONP:.trf=.f) $(CLEAN_SHYUDINRHO:.trf=.f) \
	   $(CLEAN_UMFYUDINRHO:.trf=.f)  \
		$(CLEAN_AK1D:.trf=.f) $(CLEAN_AK2D:.trf=.f)
	$(DEL) *.mod *.lst
